{% extends "../../layui/layouts/blank.html" %}

{% block mainbody %}
<div class="admin-form form-block">
    <form class="layui-form layui-form-pane" lay-filter="_FORM" id="admin2-form">
        <div class="layui-form-item field-user-name">
            <label class="layui-form-label" for="user-name">账号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="username" lay-verify="required">
                <div class="help-block"></div>
            </div>
        </div>
        <div class="layui-form-item field-user-username required">
            <label class="layui-form-label" for="user-username">昵称</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="nickname" lay-verify="required">
                <div class="help-block"></div>
            </div>
        </div>
        <div class="layui-form-item field-user-email required">
            <label class="layui-form-label" for="user-email">类型</label>
            <div class="layui-input-block">
                <input type="hidden" name="type" value="1">
                <div role="radiogroup">
                    {% ifequal Admin.Type 1 %}
                    <input type="radio" name="type" value="1" disabled checked title="药品">
                    {% endifequal %}
                    {% ifequal Admin.Type 2 %}
                    <input type="radio" name="type" value="2" disabled checked title="医疗器械">
                    {% endifequal %}
                    <div class="help-block"></div>
                </div>
            </div>
        </div>
        <div class="layui-form-item field-user-username required">
            <label class="layui-form-label" for="user-username">省</label>
            <div class="layui-input-block">
                <select name="province" class="province-selector" data-value="河南省" lay-filter="province-1" lay-verify="required">
                    <option value="">请选择省</option>
                </select>
                <div class="help-block"></div>
            </div>
        </div>
        <div class="layui-form-item field-user-username required">
            <label class="layui-form-label" for="user-username">市</label>
            <div class="layui-input-block">
                <select name="city" class="city-selector" data-value="郑州市" lay-filter="city-1">
                    <option value="">请选择市</option>
                </select>
                <div class="help-block"></div>
            </div>
        </div>
        <div class="layui-form-item field-user-username required">
            <label class="layui-form-label" for="user-username">区</label>
            <div class="layui-input-block">
                <select name="county" class="county-selector" data-value="高新区" lay-filter="county-1">
                    <option value="">请选择区</option>
                </select>
                <div class="help-block"></div>
            </div>
        </div>

        <div class="layui-form-item layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="_SUBMIT_FORM">
                立即提交
            </button>
        </div>
    </form>
</div>
{% endblock %}

{% block script %}
<script>
    layui.use(['form', 'ax', 'helper', 'layarea'], function() {
        var form = layui.form, ax = layui.ax, layarea = layui.layarea;

        layarea.render({
            elem: '#admin2-form',
            change: function (res) {
                //选择结果
                console.log(res)
            }
        });


        form.on('submit(_SUBMIT_FORM)', function (data) {
            var ajax = new ax("/admin/create", function(res) {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index)
            });
            ajax.setMethod('post');
            ajax.setDataData(data.field);
            ajax.send();
            return false;
        })
    })
</script>
{% endblock %}